<?php
require_once 'Response.php';
require_once 'DB.php';

$item = (array)json_decode(file_get_contents( "php://input"));

//2. 存入数据库
$sql = "INSERT `add` (name, tel, address, users) VALUES ('".$item['name']."', '".$item['tel']."', '".$item['detail']."', '".$item['users']."');
        alter table `add` drop id;
        alter table `add` add id int not null primary key auto_increment first;";
$pdo = DB::getInstance()->connect();
$count  =  $pdo->exec($sql); //返回受影响的行数

//3. 结果返回
Response::json(200, '添加成功！', ['id'=>$pdo->lastInsertId()]);